home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / renderChecker.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  39.4 KB  |  978 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //    Rendering Diagnostics...
  19. //        FileName: renderChecker.mel
  20. //        Usage: "renderChecker #triangles_limit",
  21. //           where #triangles_limit is what you consider to be a high
  22. //           tessellation count; we recommend 10000.
  23. //
  24. //    Maya Limitations.
  25. //    This script searches for the following scenarios specific to Maya3.0:
  26. //        - motion blur limitations
  27. //        - output image file format restrictions
  28. //        - byframe of 0 causing hang
  29. //        - fractional byframe requiring modify ext
  30. //        - no renderable cameras or weird combination
  31. //        - 2d blur with colored background will have artifacts
  32. //        - large far/near clipping plane values cause artifacts
  33. //        - reflection gets incorrect normal when bumped
  34. //        - instanced light not work too well
  35. //        - zero-scale items not rendered
  36. //
  37. //    The following Warnings may be issued:
  38. //        - no lights warning
  39. //        - composite rendering warning
  40. //        - RT global flag on but no real RT being requested
  41. //        - RT shadows turned on but RT global flag is not
  42. //        - small filter value warning
  43. //        - misuse of the "useMaximumRes" attribute causing flickering
  44. //        - file texture name delimited by "." warning
  45. //        - bump map does not work with file texture's advanced filtering
  46. //        - missing file texture warning
  47. //        - SG with no ports connected
  48. //        - object with no SG associated
  49. //        - screen-space tessellation resulting in flicker
  50. //        - dangling volume primitives (fog/glow)
  51. //        - shadow map reuse may be dangerous due to autofocus
  52. //        - shader glow flicker with auto-exposure turned on
  53. //
  54. //    Warnings for the following scenarios which affect Performance:
  55. //        - suggestion of using 2d motion blur instead of 3d motion blur
  56. //        - RT warning, and RT limits
  57. //        - high shading sample warning
  58. //        - high visibility sample warning
  59. //        - lots of textures not using file caching warning
  60. //        - inefficient use of layered shader causing slowdown
  61. //        - avoid RT shadows
  62. //        - avoid large filter size values for shadow map
  63. //        - avoid large shadow map resolution
  64. //        - output objects with high tessellation count (nurbs + subdivs)
  65. //        - degree 1 tessellation suggestion
  66. //
  67.  
  68. global string $renderableCamera;
  69.  
  70. global proc renderChecker(int $numTri)
  71. {
  72.     print "\nStarting diagnostics...\n\n\n";
  73.     print "Known Problems/Limitations\n";
  74.     print "--------------------------\n";
  75.     maya1_0_bugs_diagnostic();
  76.     print "\n";
  77.  
  78.     print "Warnings\n";
  79.     print "--------\n";
  80.     warning_diagnostic();
  81.     print "\n";
  82.  
  83.     print "Speed/Memory Implications\n";
  84.     print "-------------------------\n";
  85.     performance_diagnostic($numTri);
  86.     print "\n\nDiagnostic Completed...\n\n";
  87. }
  88.  
  89.  
  90. global proc maya1_0_bugs_diagnostic()
  91. {
  92.     string $renderQuality[] = `listConnections defaultRenderGlobals.qual`;
  93.  
  94.     if (`getAttr defaultRenderGlobals.mb` &&
  95.         `getAttr ($renderQuality[0] + ".ert")`)
  96.     {
  97.         print "    - motion blur and raytracing are both turned on.  Please note\n";
  98.         print "      that reflections, refractions and shadows are not motion blurred.\n";
  99.     }
  100.  
  101.     if (`getAttr defaultRenderGlobals.mb`)
  102.     {
  103.         print "    - you have motion blur turned on.  Be aware that particles,\n";
  104.         print "      lights and shadows do not motion blur.  As well, motion\n";
  105.         print "      blurred shadows may produce artifacts - a thorough discussion\n";
  106.         print "      of the shadowing issues is available in the rendering release notes.\n";
  107.     }
  108.  
  109.     int $format = `getAttr defaultRenderGlobals.outf`;
  110.     if ($format != 7 && $format != 10)
  111.     {
  112.         if ($format == 3 || $format == 4)
  113.         {
  114.             print "    - you have specified output to the TIFF format.  This will write out LZW\n";
  115.             print "      compressed TIFF images for version 5.  Applications which can only handle\n";
  116.             print "      version 4 TIFF may not be able to read Maya's TIFF images.  A possible\n";
  117.             print "      workaround is to write to uncompressed TIFF images, which can be achieved\n";
  118.             print "      by typing \"setenv IMF_TIFF_COMPRESSION none\".  Uncompressed TIFF is also\n";
  119.             print "      ideal for Zap!It.\n";
  120.         }
  121.  
  122.         if ($format == 12)
  123.         {
  124.             print "    - you have specified output to the Quantel format.  This format may only\n";
  125.             print "      be output to NTSC/PAL/HDTV resolutions, and does not output to fields.\n";
  126.             print "      If the above restrictions are not met, rendering will default to IFF\n";
  127.             print "      image output.\n";
  128.         }
  129.  
  130.         if ($format == 11)
  131.         {
  132.             print "    - you have specified output to the Cineon format.  This format\n";
  133.             print "      will not render out a mask channel.\n";
  134.         }
  135.  
  136.         if ($format == 0 || $format == 8 || $format == 9)
  137.         {
  138.             print "    - output to GIF/EPS/JPEG formats will result in the mask channel not being\n"; 
  139.             print "      written.\n";
  140.         }
  141.     }
  142.  
  143.     if (`getAttr defaultRenderGlobals.an` && `getAttr defaultRenderGlobals.bfs` == 0.0)
  144.     {
  145.         print "    - the animation by-frame step is 0.  Please be aware that this may result\n";
  146.         print "      in an infinite loop - 0 for by-frame is not meaningful.\n";
  147.     }
  148.  
  149.     if (`getAttr defaultRenderGlobals.an` && `getAttr defaultRenderGlobals.me` == 0 &&
  150.         `getAttr defaultRenderGlobals.bfs` > -1.0 && `getAttr defaultRenderGlobals.bfs` < 1.0)
  151.     {
  152.         print "    - you have specified a fractional animation by-frame step.  This will result\n";
  153.         print "      in images over-writing each other for fractional frame counts.  Please\n";
  154.         print "      remember to turn on the modify-extension.\n";
  155.     }
  156.  
  157.  
  158.     int $gotRenderableCamera = 0;
  159.     string $allCameras[] = `ls -ca`;
  160.     global string $renderableCamera;
  161.     for ($i = 0; $i < size($allCameras); $i++)
  162.     {
  163.         if (`getAttr ($allCameras[$i] + ".rnd")`)
  164.         {
  165.             $gotRenderableCamera = 1;
  166.             $renderableCamera = $allCameras[$i];
  167.             if (`getAttr ($allCameras[$i] + ".img")` == 0)
  168.                 print ("    - " + $allCameras[$i] + "'s rendering won't have the color channel written out.\n");
  169.             if (`getAttr ($allCameras[$i] + ".bfc")` == 0 &&
  170.                 `getAttr ($allCameras[$i] + ".fcp")` / `getAttr ($allCameras[$i] + ".ncp")` > 100000.0)
  171.             {
  172.                 print ("    - " + $allCameras[$i] + "'s near/far clipping values are too far apart - you may\n");
  173.                 print "      enounter numerical imprecision resulting in incorrect renders.\n";
  174.             }
  175.         }
  176.     }
  177.     if ($gotRenderableCamera == 0)
  178.         print "    - there are no renderable cameras in your scene.\n";
  179.  
  180.     if (`getAttr defaultRenderGlobals.mb` && `getAttr defaultRenderGlobals.mbt` == 0) 
  181.     {
  182.         for ($i = 0; $i < size($allCameras); $i++)
  183.         {
  184.             if (`getAttr ($allCameras[$i] + ".rnd")`)
  185.             {
  186.                 if (`getAttr ($allCameras[$i] + ".colr")` != 0 ||
  187.                     `getAttr ($allCameras[$i] + ".colg")` != 0 ||
  188.                     `getAttr ($allCameras[$i] + ".colb")` != 0) {
  189.                     print "    - 2d motion blur is used with a colored background.  This will likely\n"; 
  190.                     print "      produce edge artifacts.  Turning on the 2d motion blur's 'smooth color'\n";
  191.                     print "      attribute will resolve those artifacts.\n";
  192.                     break;
  193.                 }
  194.             }
  195.         }
  196.     }
  197.  
  198.  
  199.     string $allShaders[] = `ls -materials`;
  200.     for ($i = 0; $i < size($allShaders); $i++)
  201.     {
  202.         string $ntype = `nodeType $allShaders[$i]`;
  203.         if ($ntype == "blinn" || $ntype == "phong" || $ntype == "phongE" || $ntype == "lambert" || $ntype == "anisotropic")
  204.         {
  205.             string $bump[] = `listConnections ($allShaders[$i] + ".n")`;
  206.             string $refl[] = `listConnections ($allShaders[$i] + ".c")`;
  207.             string $refl2[];
  208.             if ($ntype != "lambert")
  209.                 $refl2 = `listConnections ($allShaders[$i] + ".rc")`;
  210.             if (size($bump) != 0 && size($refl) != 0 && size($refl2) != 0)
  211.             {
  212.                 $ntype = `nodeType $refl[0]`;
  213.                 if ($ntype == "envBall" || $ntype == "envChrome" || 
  214.                     $ntype == "envCube" || $ntype == "envSky") 
  215.                 {
  216.                     print ("    - " + $allShaders[$i] + " has both its bump and environment map connected.  Please be\n");
  217.                     print "      aware of the limitation that the reflection will not be bumped unless you\n";
  218.                     print "      invoke a MEL proc - cnctBumpProjNormal MATERIAL - see rendering release notes.\n";
  219.                 }
  220.             }
  221.         }
  222.     }
  223.  
  224.  
  225.     string $allLights[] = `ls -lights`;
  226.     for ($i = 0; $i < size($allLights); $i++)
  227.     {
  228.         string $ntype = `nodeType $allLights[$i]`;
  229.         if ($ntype == "spotLight" || $ntype == "pointLight" || $ntype == "volumeLight" || $ntype == "areaLight")
  230.         {
  231.             string $transf[] = `ls -dag -ap ($allLights[$i])`; 
  232.             if (size($transf) > 1)
  233.             {
  234.                 print ("    - " + $allLights[$i] + " appears to be an instanced light.  It is best\n");
  235.                 print "      to avoid instanced lights - copying lights would be recommended.\n";
  236.             }
  237.         }
  238.     }
  239.  
  240.     zeroScale_problem();
  241. }
  242.  
  243.  
  244. global proc warning_diagnostic()
  245. {
  246.     string $renderQuality[] = `listConnections defaultRenderGlobals.qual`;
  247.     string $rez[] = `listConnections defaultRenderGlobals.res`;
  248.  
  249.     string $lights[] = `ls -lights`;
  250.     if (size($lights) == 0 && `getAttr defaultRenderGlobals.enableDefaultLight` == 0)
  251.         print "    - you have no lights to illuminate your scene.\n";
  252.  
  253.     if (`getAttr defaultRenderGlobals.comp`)
  254.     {
  255.         print "    - you have turned on composite rendering.  Be aware that the\n";
  256.         print "      rendering will appear aliased, but will be ideal once you complete\n";
  257.         print "      your compositing work.\n";
  258.     }    
  259.  
  260.     int    $i;
  261.     string $allShapes[] = `ls -dag -typ shape`;
  262.     if (`getAttr ($renderQuality[0] + ".ert")`)
  263.     {
  264.         if (`getAttr ($renderQuality[0] + ".rfl")` == 0)
  265.             print "    - no RT reflections will be rendered (renderQuality's global RT reflection control is switched off).\n";
  266.         if (`getAttr ($renderQuality[0] + ".rfr")` == 0)
  267.             print "    - no RT refractions will be rendered (renderQuality's global RT refraction control is switched off).\n";
  268.         if (`getAttr ($renderQuality[0] + ".sl")` == -1)
  269.             print "    - no RT shadows will be rendered (renderQuality's global RT shadow control is switched off).\n";
  270.  
  271.         int    $gotERT = 0;
  272.         for ($i = 0; $i < size($allShapes); $i++) 
  273.         {
  274.             string $type = `objectType $allShapes[$i]`;
  275.             switch ($type) 
  276.             {
  277.                 case "subdiv":
  278.                 case "nurbsSurface":
  279.                 case "mesh":
  280.                 case "polymesh":
  281.                 case "particle":
  282.                     if (`getAttr ($allShapes[$i] + ".visibleInReflections")` ||
  283.                         `getAttr ($allShapes[$i] + ".visibleInRefractions")`)
  284.                         $gotERT = 1;
  285.                     break;
  286.             }
  287.             if ($gotERT) break;
  288.         }
  289.         string $allLights[] = `ls -lights`;
  290.         for ($i = 0; $i < size($allLights); $i++)
  291.         {
  292.             if (`getAttr ($allLights[$i] + ".urs")`)
  293.                 $gotERT = 1;
  294.         }
  295.         if ($gotERT == 0)
  296.             print "    - raytracing is turned on, but no objects have been marked for raytracing.\n";
  297.     }
  298.     else
  299.     {
  300.         int $gotRTshadows = 0;
  301.         string $allLights[] = `ls -lights`;
  302.         for ($i = 0; $i < size($allLights); $i++)
  303.         {
  304.             if (`getAttr ($allLights[$i] + ".urs")`)
  305.                 $gotRTshadows = 1;
  306.         }
  307.         if ($gotRTshadows)
  308.         {
  309.             print "    - raytracing shadows are specified but the render globals' raytracing flag\n";
  310.             print "      is not turned on.  Those raytracing shadows will not be computed.\n";
  311.         }
  312.     }
  313.  
  314.  
  315.     int $i;
  316.     string $allTextures[] = `ls -textures`;
  317.     for ($i = 0; $i < size($allTextures); $i++)
  318.     {
  319.         if (`nodeType $allTextures[$i]` == "file" && `getAttr ($allTextures[$i] + ".f")` < 0.1)
  320.         {
  321.             print ("    - " + $allTextures[$i] + "'s filter value is very small.  This can result in bad aliasing.\n");
  322.             if (`getAttr ($allTextures[$i] + ".ft")` != 1)
  323.                 print "      Furthermore, performance can be severely affected when used with non-mipmap mode.\n";
  324.         }
  325.         if (`nodeType $allTextures[$i]` == "file" && `getAttr ($allTextures[$i]
  326. + ".umr")`)
  327.         {
  328.             print ("    - " + $allTextures[$i] + " has useMaximumRes turned on.  This attribute is not intended\n");
  329.             print ("      to provide highest image quality, but use the highest resolution in the mipmap.\n");
  330.             print ("      As such, it may even produce undersirable artifacts.  To turn it off, type:\n");
  331.             print ("      setAttr " + $allTextures[$i] + ".umr 0.\n");
  332.  
  333.         }
  334.         if (`nodeType $allTextures[$i]` == "file" && `getAttr ($allTextures[$i] + ".ufe")`)
  335.         {
  336.             string $tmp[];
  337.             string $filename = `getAttr ($allTextures[$i] + ".ftn")`;
  338.             tokenize ($filename, ".", $tmp);
  339.             if (size ($tmp) > 2)
  340.             {
  341.                 print ("    - " + $allTextures[$i] + "'s file texture name has more than one '.' delimiter.\n");
  342.                 print "      This may produce erroneous frame parsing for animated textures.  Please refer\n";
  343.                 print "      to the rendering release notes for more information on this restriction.\n";
  344.             }
  345.         }
  346.         if (`nodeType $allTextures[$i]` == "file")
  347.         {
  348.             int $resolutionX = `getAttr ($allTextures[$i] + ".outSizeX")`;
  349.             int $resolutionY = `getAttr ($allTextures[$i] + ".outSizeY")`;
  350.             if ($resolutionX == 0 || $resolutionY == 0)
  351.             {
  352.                 print ("    - " + $allTextures[$i] + " is missing a file texture on disk.\n");
  353.             }
  354.         }
  355.     }
  356.  
  357.  
  358.     string $sets[] = `ls -sets`;
  359.     for ($i = 0; $i < size($sets); $i++) 
  360.     {
  361.         if (`sets -q -renderable $sets[$i]`) 
  362.         {
  363.             string $ss[] = `listConnections ($sets[$i] + ".surfaceShader")`;
  364.             string $vs[] = `listConnections ($sets[$i] + ".volumeShader")`;
  365.             if (size($ss) == 0 && size($vs) == 0)
  366.                 print ("    - " + $sets[$i] + " has no port connected.  This can be dangerous for rendering.\n");
  367.         }
  368.     }
  369.  
  370.  
  371.     string $activeObjects[] = `ls -sl`;
  372.     int $firsttime = 1;
  373.     for ($i = 0; $i < size($allShapes); $i++)
  374.     {
  375.         string $type = `objectType $allShapes[$i]`;
  376.         switch ($type)
  377.         {
  378.             case "subdiv":
  379.             case "mesh":
  380.             case "polymesh":
  381.             case "renderCone":
  382.             case "renderSphere":
  383.             case "directedDisc":
  384.                 int $j;
  385.                 string $sets[] = `listConnections ($allShapes[$i] + ".iog")`;
  386.                 for ($j = 0; $j < size($sets); $j++)
  387.                     if (`objectType ($sets[$j])` == "shadingEngine" &&
  388.                         `sets -q -renderable ($sets[$j])`) break;
  389.                 if ($j == size($sets))
  390.                 {
  391.                     if ($firsttime == 1)
  392.                     {
  393.                         $firsttime = 0;
  394.                     }
  395.                     select -r $allShapes[$i];
  396.                     string $shadingGroup[] = `ls -sl -type shadingEngine`;
  397.                     if (size($shadingGroup) == 0)
  398.                     {
  399.                         if ( $type == "renderCone" || $type == "renderSphere" || $type == "directedDisc" )
  400.                         {
  401.                             print ("    - " + $allShapes[$i] + " has no shading group associated with it.  This\n");
  402.                             print "      means that it will not be rendered.  This is usually a residue of\n";
  403.                             print "      disconnection of light fog/glow. You may wish to delete this.\n";
  404.                         }
  405.                         else
  406.                         {
  407.                             print ("    - " + $allShapes[$i] + " has no shading group associated with it.  This\n");
  408.                             print "      means that it will not be rendered.  Please assign it to a shading group.\n";
  409.                         }
  410.                     }
  411.                 }
  412.                 break;
  413.  
  414.             case "nurbsSurface":
  415.             case "particle":
  416.                 int $j;
  417.                 string $sets[] = `listConnections ($allShapes[$i] + ".iog")`;
  418.                 for ($j = 0; $j < size($sets); $j++)
  419.                     if (`objectType ($sets[$j])` == "shadingEngine" &&
  420.                         `sets -q -renderable ($sets[$j])`) break;
  421.                 if ($j == size($sets))
  422.                 {
  423.                        print ("    - " + $allShapes[$i] + " has no shading group associated with it.  This\n");
  424.                        print "      means that it will not be rendered.  Please assign it to a shading group.\n";
  425.                 }
  426.  
  427.                 if (`attributeQuery -exists -node $allShapes[$i] modeU`)
  428.                 {
  429.                     if (`getAttr ($allShapes[$i] + ".modeU")` == 4 ||
  430.                         `getAttr ($allShapes[$i] + ".modeV")` == 4)
  431.                     {
  432.                         print ("    - " + $allShapes[$i] + " is tesselated with the screen-space option.\n");
  433.                         print "      If this object also contains a solid texture, the different tessellations\n";
  434.                         print "      over an animation may result in the appearance of solid texture flicker.\n";
  435.                     }
  436.                 }
  437.                 break;
  438.         }
  439.     }
  440.  
  441.     volumeGeomTest();
  442.  
  443.     string $allStrokes[] = `ls -type stroke`;
  444.     global string $renderableCamera;
  445.     if (size($allStrokes) != 0) {
  446.         // There are Paint Effects strokes in the scene.
  447.         // First, check if the depth type on the camera is ideally suited to Paint Effects.
  448.         if (`getAttr ($renderableCamera + ".depthType")` == 0) {
  449.             if (`getAttr ($renderableCamera + ".transparencyBasedDepth")` == 0) {
  450.                 print("    - " + $renderableCamera + "'s Output Settings, Depth Type is set to 'Closest Visible Depth',\n");
  451.                 print("      'Transparency Based Depth' is OFF and there are Paint Effects strokes in the scene. This can\n");
  452.                 print("      result in a halo-like rim around objects which have Paint Effects behind them. To fix this,\n");
  453.                 print("      open the Attribute Editor for the renderable camera (in this case " + $renderableCamera + ")\n");
  454.                 print("      and in the Output Settings section, select Depth, and set Depth Type to 'Furthest Visible Depth'.\n");
  455.                 print("      If you require 'Closest Visible Depth' for some other reason, select 'Transparency Based Depth'\n");
  456.                 print("      and set the 'Threshold' low enough to avoid the fringing. Start at a value of .25 and see if the\n");
  457.                 print("      halo fringes around your objects are gone the next time you render. If not, you will need to reduce\n");
  458.                 print("      the Threshold value further.\n");
  459.             }
  460.         }
  461.         // Secondly, check that the lights in the scene do not have Mid-dist or raytracing shadows enabled.
  462.         string $allLights[] = `ls -lights`;
  463.         for ($i = 0; $i < size($allLights); $i++)
  464.         {
  465.             string $ntype = `nodeType $allLights[$i]`;
  466.             if ($ntype == "spotLight" || $ntype == "pointLight" || $ntype == "volumeLight" || $ntype == "directionalLight")
  467.             {
  468.                 // These light types can have depth mapped shadows.
  469.                 if (`getAttr ($allLights[$i] + ".useDepthMapShadows")`) {
  470.                     if (`getAttr($allLights[$i] + ".useMidDistDmap")`) {
  471.                         print("    - " + $allLights[$i] + " is casting depth map shadows with 'Use Mid Dist Dmap' enabled and there\n");
  472.                         print("      are Paint Effects strokes in the scene. Paint Effects strokes may not shadow correctly or may not\n");
  473.                         print("      cast shadows correctly if 'Use Mid Dist Dmap' is on for shadow maps. It is best to de-select the\n");
  474.                         print("      'Use Mid Dist Dmap' option for shadow casting lights when Paint Effects are in the scene.\n");
  475.                     }
  476.                 }
  477.             }
  478.             if (`getAttr( $allLights[$i] + ".useRayTraceShadows")`) {
  479.                 print("    - " + $allLights[$i] + " has 'Use Ray Trace Shadows' selected and there are Paint Effects strokes in the scene.\n");
  480.                 print("      Paint Effects strokes cannot cast raytrace shadows, they can only cast depth map shadows or fake shadows\n");
  481.                 print("      (as specified on the brush). Paint Effects strokes will also not be visible in raytraced reflections and\n");
  482.                 print("      refractions. If you wish to raytrace Paint Effects, you will need to devise reflection mapping or\n");
  483.                 print("      compositing solutions.\n");
  484.             }
  485.         }
  486.         if (`getAttr ("defaultRenderGlobals.onlyRenderStrokes")`) {
  487.             print("    - The Render Globals Paint Effects Rendering Option 'Only Render Strokes' is enabled. This means that\n");
  488.             print("      a primary rendering pass is not being performed, only strokes will be rendered. A consequence of this\n");
  489.             print("      is that shadow maps are not being generated so shadowing of Paint Effects strokes, and the shadows of\n");
  490.             print("      Paint Effects strokes may be wrong. To have shadows properly cast onto Paint Effects strokes, be sure\n");
  491.             print("      that the lights in the scene have their 'Disk Based Dmaps' attribute set to 'Reuse Existing Dmap(s)'.\n");
  492.             print("      To have Paint Effects strokes cast shadows properly, do a shadow map rendering pass before rendering\n");
  493.             print("      your geometry image; set all shadow depth map producing light's 'Disk Base Dmaps' to 'Overwrite Existing\n");
  494.             print("      Dmap(s)' and render the full scene with 'Only Render Strokes' de-selected (OFF). Then set the 'Disk Based Dmaps'\n");
  495.             print("      back to 'Reuse Existing Dmap(s)' and 'Enable Stroke Rendering' de-selected, and then render the geometry\n");
  496.             print("      only pass.\n");
  497.             string $depthFile = `getAttr ("defaultRenderGlobals.strokesDepthFile")`;
  498.             if ($depthFile == "") {
  499.                 print("    - The Render Globals Paint Effects Rendering Option 'Only Render Strokes' is enabled, but you have\n");
  500.                 print("      not supplied a source depth file for the Paint Effects to render against. This means that all Paint\n");
  501.                 print("      Effects strokes will render regardless of their visibility when they are composited into your final\n");
  502.                 print("      scene. If the file you supply as a depth file has no color information, the Paint Effects strokes\n");
  503.                 print("      will render against the background color. If the depth file has color, the Paint Effects strokes will\n");
  504.                 print("      render against the depth file's image. Allowing Paint Effects to render against the depth file's image\n");
  505.                 print("      will produce superior results to what a post-process compositing package can do. The Paint Effects\n");
  506.                 print("      rendering process uses a multi-depth buffer compositing process which cannot be duplicated in a\n");
  507.                 print("      post-process composite. See the Paint Effects documentation for more information on how to use\n");
  508.                 print("      'Only Render Strokes' to add Paint Effects to existing images (which is the best way to use non-Maya\n");
  509.                 print("      renderers and combine Paint Effects with their output.\n");
  510.             }
  511.         }
  512.     }
  513.  
  514.  
  515.     for ($i = 0; $i < size($lights); $i++)
  516.     {
  517.         string $ntype = `nodeType $lights[$i]`;
  518.         if ($ntype == "directionalLight" || $ntype == "spotLight" || 
  519.             $ntype == "pointLight" || $ntype == "volumeLight" || $ntype == "areaLight")
  520.         {
  521.             if (`getAttr ($lights[$i] + ".useDmapAutoFocus")` && 
  522.                 `getAttr ($lights[$i] + ".reuseDmap")` &&
  523.                 `getAttr ($lights[$i] + ".useDepthMapShadows")`)
  524.             {
  525.                 print("    - " + $lights[$i] + " has auto focus + reuse depth map turned on.\n");
  526.                 print("      This may cause inconsistent shadow results if you produced the\n");
  527.                 print("      the shadow map, then changed any of the angle of view, turned on/off\n");
  528.                 print("      the shadow casting option for some objects, transformed objects,\n");
  529.                 print("      turned off the auto focus, etc.  Might be best to turn off auto focus\n");
  530.                 print("      when you produce the shadow map.\n");
  531.             }
  532.         }
  533.     }
  534.  
  535.     // Warning about glow flicker with auto-exposure on.
  536.     int $autoExposureOn = 0;
  537.     string $shaderGlowNode[] = `ls -type shaderGlow`;
  538.     for ($i = 0; $i < size($shaderGlowNode); $i++)
  539.     {
  540.         if (`getAttr ($shaderGlowNode[$i] + ".autoExposure")`) 
  541.         {
  542.             $autoExposureOn = 1;
  543.             break;
  544.         }
  545.     }
  546.     if ($autoExposureOn)
  547.     {
  548.         int $glowFlickerWarning = 0;
  549.         string $shaders[] = `ls -mat`;
  550.         for ($i = 0; $i < size($shaders); $i++)
  551.         {
  552.             if (`attributeQuery -exists -node $shaders[$i] glowIntensity` &&
  553.                 `getAttr ($shaders[$i] + ".glowIntensity")` > 0.0)
  554.             {
  555.                 $glowFlickerWarning = 1;
  556.                 break;
  557.             }
  558.         }
  559.         if ($glowFlickerWarning)
  560.         {
  561.             print "    - there is shader glow in your scene, and autoExposure is turned on.\n";
  562.             print "      This may cause glow flicker over an animation.  To remedy this,\n";
  563.             print "      render one frame in which the glow intensity looks desirable, then\n";
  564.             print "      apply the normalization factor (from the rendering output) as the\n";
  565.             print "      glow intensity to the shader glow node, and also turn off autoExposure.\n";
  566.             print "      For more information, please refer to the rendering reference manual.\n";
  567.         }
  568.     }
  569.  
  570.  
  571.     if ($firsttime == 0)
  572.     {
  573.         select -r $activeObjects;
  574.     }
  575. }
  576.  
  577.  
  578. global proc performance_diagnostic(int $numTri)
  579. {
  580.     string $renderQuality[] = `listConnections defaultRenderGlobals.qual`;
  581.     string $rez[] = `listConnections defaultRenderGlobals.res`;
  582.  
  583.     if (`getAttr defaultRenderGlobals.mb` &&
  584.         `getAttr defaultRenderGlobals.mbt` == 1)
  585.     {
  586.         print "    - you have 3d motion blur turned on.  Since v2, there is a new feature\n";
  587.         print "      utilizing 2d motion blur which should work just as well, except\n";
  588.         print "      with rotational blurring.  With 2d motion blur, rendering will be\n";
  589.         print "      much faster, and a much lower shading sampling rate is needed.\n";
  590.     }
  591.  
  592.     if (`getAttr ($renderQuality[0] + ".ert")`)
  593.     {
  594.         print "    - you have raytracing turned on.  Keep in mind that raytracing is\n";
  595.         print "      inherently slow and the memory usage tends to be very large.\n";
  596.         if (`getAttr ($renderQuality[0] + ".rfl")` > 2)
  597.         {
  598.             print "    - the raytrace reflection limit is very high.  This can result\n";
  599.             print "      very long rendering times, particularly with a high refraction\n";
  600.             print "      limit and transparent surfaces.\n";
  601.         }
  602.     }
  603.  
  604.     if (`getAttr ($renderQuality[0] + ".ss")` > 3)
  605.     {
  606.         print "    - your render quality's shading sample value is quite high.  This\n";
  607.         print "      will slow down the render times.  If the image quality is not high enough,\n";
  608.         print "      it is best to increase the maximum shading samples value or turn on multi-\n";
  609.         print "      pixel filtering.  If that does not work, consider decreasing the contrast\n";
  610.         print "      threshold values (see Contrast Sensitive Production preset) to anti-\n";
  611.         print "      alias details better.  If that fails, please refer to the user manual,\n";
  612.         print "      \"Optimizing Maya's Renderer\", for tricks + tips to get better image quality.\n";
  613.     }
  614.     
  615.     if (`getAttr defaultRenderGlobals.mb` &&
  616.         `getAttr ($renderQuality[0] + ".mvs")` > 2)
  617.     {
  618.         print "    - your render quality's visibility sample value is quite high.  This\n";
  619.         print "      will slow down the render times.  If the image quality is not high enough,\n";
  620.         print "      it is best to increase the maximum visibility samples value first.  If it\n";
  621.         print "      does not work, please refer to the user manual, under \"Optimizing Maya's\n";
  622.         print "      Renderer\" for tricks + tips to get better image quality.\n";
  623.     }
  624.  
  625.     int $i;
  626.     int $numFileTextures = 0;
  627.     string $allTextures[] = `ls -textures`;
  628.     for ($i = 0; $i < size($allTextures); $i++)
  629.     {
  630.         if (`nodeType $allTextures[$i]` == "file" && `getAttr ($allTextures[$i] + ".uca")` == 0)
  631.             $numFileTextures = $numFileTextures + 1;
  632.     }
  633.     if ($numFileTextures > 20)
  634.     {
  635.         print "    - you have quite a few file textures in use.  You might want to consider\n";
  636.         print "      using texture file caching to reduce memory usage.\n";
  637.     }
  638.  
  639.  
  640.     string $shadingGroup[] = `ls -type shadingEngine`;
  641.     for ($i = 0; $i < size($shadingGroup); $i++)
  642.     {
  643.         string $members[] = `sets -query $shadingGroup[$i]`;
  644.         if (size($members) > 0)
  645.         {
  646.             string $shaderls[] = `listConnections ($shadingGroup[$i] + ".surfaceShader")`;
  647.             if (size($shaderls) != 0 &&
  648.                 `nodeType $shaderls[0]` == "layeredShader")
  649.             {
  650.                 print ("    - '" + $shaderls[0] + "' is a layered shader at the top level.\n");
  651.                 print "      It would be more optimal for the lambert/phong/phongE shader\n";
  652.                 print "      to be at the top level of the shading network, and layer\n";
  653.                 print "      textures in the rest of the shading network.\n";
  654.             }
  655.         }
  656.     }
  657.  
  658.  
  659.     string $allLights[] = `ls -lights`;
  660.     for ($i = 0; $i < size($allLights); $i++)
  661.     {
  662.         if (`getAttr ($allLights[$i] + ".urs")`)
  663.         {
  664.             print ("    - " + $allLights[$i] + " has raytrace shadows turned on.  Raytrace shadows\n");
  665.             print "      can be expensive.  Doing depth map shadows may be more economical, and\n";
  666.             print "      should be used unless transparent shadows are desired.\n";
  667.         }
  668.         if (`attributeQuery -exists -node $allLights[$i] dms` &&
  669.             `getAttr ($allLights[$i] + ".dms")`) 
  670.         {
  671.             if (`getAttr ($allLights[$i] + ".fs")` > 5)
  672.             {
  673.                 print ("    - " + $allLights[$i] + " has the shadow map filter set at a very\n");
  674.                 print "      high value.  This can make shadow map rendering very expensive.\n";
  675.                 print "      We recommend that this value be lowered.\n";
  676.             }
  677.             if (`getAttr ($allLights[$i] + ".dr")` > 1024)
  678.             {
  679.                 print ("    - " + $allLights[$i] + " has the shadow map resolution set at a very\n");
  680.                 print "      high value.  Note that the shadow blockiness artifact has been fixed\n";
  681.                 print "      and thus you don't need high resolution maps to get good shadow quality.\n";
  682.             }
  683.         }
  684.     }
  685.  
  686.  
  687.     string $allShapes[] = `ls -g -ap`;
  688.     int $hasDefaultNurbTessellation = 0;
  689.     for ($i = 0; $i < size($allShapes); $i++)
  690.     {
  691.         if (`objectType $allShapes[$i]` == "nurbsSurface") {
  692.             tessellationCount ($allShapes[$i], $numTri);
  693.             
  694.             // Does the scene contain at least one nurb surface with default
  695.             // tessellation? If the tessellation was automatically set,
  696.             // explicit tessellation is enabled.
  697.  
  698.             if (! `getAttr ($allShapes[$i]+".explicitTessellationAttributes")`) {
  699.                 $hasDefaultNurbTessellation = 1;
  700.             }
  701.         }
  702.  
  703.         if (`objectType $allShapes[$i]` == "subdiv") {
  704.             int $ofc = `getAttr ($allShapes[$i] + ".ofc")`;
  705.             int $sc = `getAttr ($allShapes[$i] + ".sc")`;
  706.             int $d = `getAttr ($allShapes[$i] + ".d")` - 1;
  707.             if ($d < 0) $d = 0;
  708.             int $powResult = `pow 4 $d`;
  709.             int $subdivCount = 2 * $ofc * $powResult * $sc * $sc;
  710.             if (`getAttr ($allShapes[$i] + ".featureDisplacement")`) {
  711.                 string $sets[] = `listConnections ($allShapes[$i] + ".iog")`;
  712.                 for ($j = 0; $j < size($sets); $j++) {
  713.                     if (`objectType ($sets[$j])` == "shadingEngine" &&
  714.                         `sets -q -renderable ($sets[$j])`) {
  715.                         string $displ[] = `listConnections ($sets[$j] + 
  716.                                                 ".displacementShader")`;
  717.                         if (size($displ) > 0) {
  718.                             int $srate = `getAttr ($allShapes[$i] + ".dsr")`;
  719.                             $subdivCount = ($subdivCount * $srate * $srate) / 2.0;
  720.                             break;
  721.                         }
  722.                     }
  723.                 }
  724.             }
  725.             if ($subdivCount > $numTri) {
  726.                 print ("    - " + $allShapes[$i] + " has a high tessellation count: " + $subdivCount + ".\n");
  727.                 print "      It will be worthwhile to reduce the tessellation amount.\n";
  728.             }
  729.         }
  730.     }
  731.  
  732.     // Is there at least one surface with default tessellation ?
  733.  
  734.     if ($hasDefaultNurbTessellation) {
  735.         // The user probably hasn't run "Set NURBS Tessellation".
  736.  
  737.         print "    - using Render->Set NURBS Tessellation[] can improve image quality\n";
  738.         print "      and reduce render time by automatically setting the optimum\n";
  739.         print "      tessellation based on distance from the camera. The tessellation\n";
  740.         print "      can be computed for multiple surfaces across all frames in the\n";
  741.         print "      animation.\n";
  742.     }
  743.  
  744.     print "    - it can be useful to run your scene through \"maya -optimizeRender\"\n";
  745.     print "      before rendering.  This can help optimize the scene for rendering.\n";
  746. }
  747.  
  748.  
  749. global proc tessellationCount (string $nodeName, int $numTri)
  750. {
  751.     string $nodeAttrNumberU = $nodeName + ".numberU";
  752.     string $nodeAttrNumberV = $nodeName + ".numberV";
  753.     string $nodeAttrModeU = $nodeName + ".modeU";
  754.     string $nodeAttrModeV = $nodeName + ".modeV";
  755.     string $nodeAttrSpansU = $nodeName + ".spansU";
  756.     string $nodeAttrSpansV = $nodeName + ".spansV";
  757.     string $nodeAttrExpert = $nodeName + ".eta";
  758.     string $nodeAttrFactU  = $nodeName + ".nufa";
  759.     string $nodeAttrFactV  = $nodeName + ".nvfa";
  760.     string $nodeAttrCurvTol = $nodeName + ".cvto";
  761.     string $nodeAttrEdgeSm = $nodeName + ".ues";
  762.     int    $valueU = `getAttr $nodeAttrNumberU`;
  763.     int    $valueV = `getAttr $nodeAttrNumberV`;
  764.     int    $modeU  = `getAttr $nodeAttrModeU`;
  765.     int    $modeV  = `getAttr $nodeAttrModeV`;
  766.     int    $spansU = `getAttr $nodeAttrSpansU`;
  767.     int    $spansV = `getAttr $nodeAttrSpansV`;
  768.     int       $expert = `getAttr $nodeAttrExpert`;
  769.     float  $factU  = `getAttr $nodeAttrFactU`;
  770.     float  $factV  = `getAttr $nodeAttrFactV`;
  771.     int       $curvTol = `getAttr $nodeAttrCurvTol`;
  772.     int       $edgeSm = `getAttr $nodeAttrEdgeSm`;
  773.  
  774.     int    $number = 0;
  775.     int       $minimal_subdiv = 0;
  776.  
  777.     if (!$expert)
  778.     {
  779.         if ($factU <= 1.5 && $factV <= 1.5) $minimal_subdiv = 1;
  780.  
  781.         $factU = $factU * (float)$spansU;
  782.         $factV = $factV * (float)$spansV;
  783.         $number = $factU * $factV * 2.0;
  784.     }
  785.     else if ($modeU == 4 || $modeV == 4) 
  786.     {
  787.         // If the mode is 4, we will really use mode 2 internally,
  788.         // and it is tough to estimate what number will be set, but
  789.         // we know the minimum.
  790.         $number = $spansU * $spansV * 2; // At a minimum.
  791.     } 
  792.     else 
  793.     {
  794.         if ($modeU == 1 || $modeU == 2) 
  795.         {
  796.             $number = $valueU;
  797.         }
  798.         if ($modeU == 3) 
  799.         {
  800.             $number = $spansU * $valueU;
  801.         }
  802.         if ($modeV == 1 || $modeV == 2) 
  803.         {
  804.             $number = $number * $valueV;
  805.         }
  806.         if ($modeV == 3) 
  807.         {
  808.             $number = $number * ($spansV * $valueV);
  809.         }
  810.         $number = $number * 2; // Each quadrilateral is split into 2 triangles.
  811.     }
  812.  
  813.     if ($edgeSm) $number = $number * 2;
  814.  
  815.     if (`getAttr ($nodeName + ".featureDisplacement")`) {
  816.         int $j;
  817.         string $sets[] = `listConnections ($nodeName + ".iog")`;
  818.         for ($j = 0; $j < size($sets); $j++) {
  819.             if (`objectType ($sets[$j])` == "shadingEngine" &&
  820.                 `sets -q -renderable ($sets[$j])`) {
  821.                 string $displ[] = `listConnections ($sets[$j] + 
  822.                                         ".displacementShader")`;
  823.                 if (size($displ) > 0) {
  824.                     int $srate = `getAttr ($nodeName + ".dsr")`;
  825.                     $number = ($number * $srate * $srate) / 2.0;
  826.                     break;
  827.                 }
  828.             }
  829.         }
  830.     }
  831.  
  832.     if ($number > $numTri)
  833.     {
  834.         print ("    - " + $nodeName + " has a high tessellation count of at least " + $number + "\n");
  835.         print "      triangles. It will be worthwhile to reduce the tessellation amount.\n";
  836.     }
  837.  
  838.     if (`getAttr ($nodeName + ".du")` == 1 || `getAttr ($nodeName + ".dv")` == 1)
  839.     {
  840.         if (!$expert)
  841.         {
  842.             if (!$minimal_subdiv)
  843.             {
  844.                 print ("    - " + $nodeName + " is a degree 1 surface.  You can usually get\n");
  845.                 print "      away with setting the tessellation at its minimum without loss of\n";
  846.                 print "      rendering quality.\n";
  847.             }
  848.         }
  849.         else
  850.         {
  851.             if (($modeU == 3 && ($valueU > 1 || $valueV > 1)) ||
  852.                 ($modeU == 1 && ($valueU > $spansU+1 || $valueV > $spansV+1)))
  853.             {
  854.                 print ("    - " + $nodeName + " is a degree 1 surface.  You can usually get\n");
  855.                 print "      away with setting the tessellation at its minimum without loss of\n";
  856.                 print "      rendering quality.\n";
  857.             }
  858.         }
  859.     }
  860. }
  861.  
  862.  
  863. global proc zeroScale_problem()
  864. {
  865.     string $globals[] = `ls -head 1 -renderGlobals`;
  866.     string $optimizeInstancesAttr = $globals[0] + ".optimizeInstances";
  867.     int $optimizeInstances = `getAttr $optimizeInstancesAttr`;
  868.  
  869.     if ($optimizeInstances) 
  870.     {
  871.         string $allTransforms[] = `ls -transforms`;
  872.  
  873.         for ($transform in $allTransforms) 
  874.         {
  875.             float $tScale[] = `xform -q -r -s $transform`;
  876.             int $finished = false;
  877.             for ($i=0; $i < 3 && !$finished; $i++) 
  878.             {
  879.                 if ($tScale[$i] <= .0002 && $tScale[$i] >= -.0002) 
  880.                 {
  881.                     $finished = true;
  882.                     print ("    - " + $transform + " has zero scale.  This can be a problem\n");
  883.                     print "      for optimize instances, so either turn optimize instances off\n";
  884.                     print "      in renderGlobals or make it invisible instead of zero scale.\n";
  885.                     print "      Zero-scale may also have problems with texture maps or shadow maps.\n";
  886.                 }
  887.             }
  888.         }
  889.     }
  890. }
  891.  
  892.  
  893. //
  894. // check for the case where lightGlow/Fog geometry is being computed in the rendering
  895. // but no glow/fog effects will show up in the final image.
  896. //  
  897. global proc volumeGeomTest() 
  898. {
  899.     // get all the lightGlow node
  900.     string $allLightGlow[] = `ls -type opticalFX`;
  901.     int $i;
  902.     for ($i = 0; $i < size($allLightGlow); $i++)
  903.     {
  904.         //
  905.         // We check for all opticalFX.message connections:
  906.         //
  907.         //    if the glowVisibility is connected to some shape and 
  908.         //    if that shape belongs to some shadingGroup and
  909.         //    if none of the message connections is made to the postProcessList1
  910.         //
  911.         // then we have the case, where the geometry will be processed for visibility
  912.         // and yet no lightGlow will show up in the final image!
  913.         //
  914.         string $geomShape[] = `listConnections -sh true ($allLightGlow[$i] + ".glowVisibility")`;
  915.         string $lightName[] = `listConnections ($allLightGlow[$i] + ".glowVisibility")`;
  916.         if ($geomShape[0] != "") 
  917.         {
  918.             //
  919.             // there is a geometry representing glowVisibility
  920.             //
  921.             string $sets[] = `listConnections ($geomShape[0] + ".iog")`;
  922.             int $j;
  923.             for ($j = 0; $j < size($sets); $j++)
  924.                 if (`objectType ($sets[$j])` == "shadingEngine" &&
  925.                     `sets -q -renderable ($sets[$j])`) break;
  926.  
  927.             if ($j != size($sets))
  928.             {
  929.                 //
  930.                 // the glow geometry belongs to some shadingGroup, it will be rendered!
  931.                 //
  932.                 // now make sure one of lightGlow.message is connected to postPorcessList1
  933.                 //
  934.                 string $msgConnections[] = `listConnections ($allLightGlow[$i] + ".message")`;
  935.                 int $activeGlow = 0;
  936.                 for ($j = 0; $j<size($msgConnections) && ($activeGlow==0); $j++) {
  937.                     //
  938.                     // determine if the lightGlow is active by checking if it is connected 
  939.                     if ($msgConnections[$j] == "postProcessList1")
  940.                         $activeGlow = 1;
  941.                 }
  942.                 if ($activeGlow==0) {
  943.                      print ("    - " + $allLightGlow[$i] + " Light glow for (" + $lightName[0] + ") is not connected to the postProcessList1.\n");
  944.                      print ("      This will slow down the renderer and yet light glow for this node will not\n");
  945.                      print ("      appear in the final rendering. \n");
  946.                 }
  947.             }
  948.         }
  949.         else 
  950.         {
  951.              print ("    - " + $allLightGlow[$i] + " does not have a geometry connected to the glowVisibility attribute.\n");
  952.              print ("      This lightGlow can never be occluded.\n");
  953.         }
  954.     }
  955.  
  956.     //
  957.     // OK, now get all the renderSphere, renderCone, and directedDisc and make sure
  958.     // They are not just dangling there.
  959.     string $miscShapes[] = `ls -type renderCone -type renderSphere -type directedDisc`;
  960.     for ($i = 0; $i < size($miscShapes); $i++)
  961.     {
  962.         string $connectedNodes[] = `listConnections $miscShapes[$i]`;
  963.         int $numConnected = size($connectedNodes);
  964.         for ($j = 0; $j < $numConnected; $j++) {
  965.             string $nodeType = `objectType $connectedNodes[$j]`;
  966.             switch ($nodeType) 
  967.             {
  968.                 case "shadingEngine":
  969.                     if ($numConnected < 2) {
  970.                          print ("    - " + $miscShapes[$i] + " is probably a residue of light fog/glow creation/disconnection.\n");
  971.                          print ("      Rendering will slow down and yet there will be no effect on the final image.\n");
  972.                     }
  973.                     break;
  974.             }
  975.         }
  976.     }
  977. }
  978.